package com.springlistener;

import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import static com.util.Printer.*;

/**
 * @Author Fizz Pu
 * @Date 2021/4/28 下午8:50
 * @Version 1.0
 * 失之毫厘，缪之千里！
 */

@Component
public class Listener2 {

    // 异步执行
    @Async
    @EventListener
    public void listenEvent(MyEvent event) throws InterruptedException {
        print("我是第三个监听器");
        Thread.sleep(1000);
        print(event.getMessage());
    }
}
